package org.kabeja.parser.entities;

import org.kabeja.dxf.entity.DXFCircle;
import org.kabeja.dxf.entity.DXFEntity;
import org.kabeja.dxf.helpers.Point;
import org.kabeja.parser.DXFValue;

/**
 * @author shutao
 * @since 2022/4/25 11:19
 */
public class DXFCircleHandler extends AbstractEntityHandler {
    public static final String ENTITY_NAME = "CIRCLE";
    public static final int RADIUS = 40;
    private DXFCircle circle;

    public DXFCircleHandler() {
    }

    @Override
    public void endDXFEntity() {
    }

    @Override
    public DXFEntity getDXFEntity() {
        return this.circle;
    }

    @Override
    public String getDXFEntityName() {
        return "CIRCLE";
    }

    @Override
    public void parseGroup(int var1, DXFValue var2) {
        switch(var1) {
            case 10:
                this.circle.getCenterPoint().setX(var2.getDoubleValue());
                break;
            case 20:
                this.circle.getCenterPoint().setY(var2.getDoubleValue());
                break;
            case 40:
                this.circle.setRadius(var2.getDoubleValue());
                break;
            default:
                super.parseCommonProperty(var1, var2, this.circle);
        }

    }

    @Override
    public void parseObject(int var1, DXFValue var2, int type) {
        super.parseObjectProperty(var1, var2, type, this.circle);
    }

    @Override
    public void startDXFEntity() {
        this.circle = new DXFCircle();
        this.circle.setCenterPoint(new Point());
        this.circle.setDXFDocument(this.doc);
    }

    @Override
    public boolean isFollowSequence() {
        return false;
    }
}
